<?php /*a:2:{s:56:"E:\source\EasyPeak\application\admin\view\auth\auth.html";i:1574777023;s:75:"E:\source\EasyPeak\application\admin\view\..\..\common\view\admin_base.html";i:1572404708;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href=" /test/static/fontawesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/test/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/test/static/admin/admin.css" media="all">
    <script src="/test/static/js/jquery.min.js"></script>
</head>
<body>
<script src="/test/static/layui/layui.js"></script>
<script>
    layui.use(['form'],function(){
        var form = layui.form;
        form.on('submit(reset)',function(){
            location.reload();
        })
    })
</script>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-form-item layui-hide">
                            <label class="layui-form-label">guid</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[guid]" value="<?php echo htmlentities((isset($model['guid']) && ($model['guid'] !== '')?$model['guid']:'')); ?>" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">上级节点</label>
                            <div class="layui-input-inline" style="width:300px;position:relative;">
                                <input type="text" name="pidtree" required="" placeholder="请输入标题" readonly="" class="layui-input" value="<?php echo htmlentities((isset($parent['name']) && ($parent['name'] !== '')?$parent['name']:'')); ?>">
                                <input type="text" name="form[pid]" class="layui-hide" value="<?php echo htmlentities((isset($parent['guid']) && ($parent['guid'] !== '')?$parent['guid']:'')); ?>">
                                <div class="eleTree pid" id="pidtree" lay-filter="pid"></div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[name]" value="<?php echo htmlentities((isset($model['name']) && ($model['name'] !== '')?$model['name']:'')); ?>" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">路径</label>
                            <div class="layui-input-inline" style="width:360px;">
                                <input type="text" name="form[action]" value="<?php echo htmlentities((isset($model['action']) && ($model['action'] !== '')?$model['action']:'')); ?>" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">图标</label>
                            <div class="layui-input-inline" style="width:320px;">
                                <input type="text" id="icon" name="form[icon]" value="<?php echo htmlentities((isset($model['icon']) && ($model['icon'] !== '')?$model['icon']:'')); ?>" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                <div class="layui-btn" id="iconselected" url="<?php echo url('publics/selecticon'); ?>">选择按钮</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-inline" style="width:160px;">
                                <input type="text" name="form[sort]" value="<?php echo htmlentities((isset($model['sort']) && ($model['sort'] !== '')?$model['sort']:0)); ?>" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">是否菜单</label>
                            <div class="layui-input-block">
                                <input type="radio" name="form[ismenu]" value="1" title="是" <?php echo !empty($model['ismenu']) ? "checked" : ""; ?> >
                                <input type="radio" name="form[ismenu]" value="0" title="否" <?php echo !empty($model['ismenu']) ? "" : "checked"; ?>>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="commit">提交</button>
                                <button class="layui-btn layui-btn-primary" lay-submit lay-filter="reset">重置</button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<link rel="stylesheet" href="/test/static/layui/css/eleTree.css">
<style>
#pidtree{
    height: auto;
    width: 100%;
    display: none;
    position: absolute;
    top: 100%;
    background-color: #fff;
    z-index: 100;
}
.eleTree {
    width: 350px;
    height: 500px;
    border: 1px solid #ccc;
    overflow: hidden;
    display: inline-block;
}
</style>
<script>
    layui.extend({
        eleTree: '{/}/test/static/layui/extend/eleTree'
    }).use(['element','layer', 'table','eleTree','form'], function() {
        var element = layui.element,
            layer = layui.layer,
            table = layui.table,
            eleTree = layui.eleTree;
        var form = layui.form;

        var pidtree;
        $("[name='pidtree']").on("click",function (e) {
            e.stopPropagation();
            if(!pidtree){
                pidtree=eleTree.render({
                    elem: '#pidtree',
                    url:"<?php echo url('admin/auth/index'); ?>?type=tree",
                    defaultExpandAll: true,
                    expandOnClickNode: false,
                    highlightCurrent: true,
                    response: {
                        dataName: "data"
                    },
                    request: {
                        name: "name",
                        key: "guid",
                        children: "children",
                        checked: "checked",
                        disabled: "disabled",
                        isLeaf: "isLeaf"
                    }
                });
            }
            $("#pidtree").toggle();
        })
        eleTree.on("nodeClick(pid)",function(d) {
            $("[name='pidtree']").val(d.data.currentData.name);
            $("[name='form[pid]']").val(d.data.currentData.guid);
            $("#pidtree").hide();
        })
        $(document).on("click",function() {
            $("#pidtree").hide();
        })

        form.on('submit(commit)', function(obj){
            $.post({
                url:document.URL
                ,type:'post'
                ,data: obj.field
                ,success:function(res){
                    if(res.code == 1){
                        layer.msg(res.msg, {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            parent.window.frames[0].document.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        });

        $("#iconselected").click(function(){
            var url = $(this).attr('url');
            top.layer.open({
                type: 2,
                title: '图标列表',
                shade: 0,
                area: ['780px', '560px'],
                content: url,
                success: function(layero,index){
                    var winname = layero.find('iframe')[0]['name'];
                    top.$("#"+winname).contents().find('.icon-item').on('click',function(){
                        var classname = $(this).find('i').prop('className');
                        $("#icon").val(classname);
                        top.layer.close(index);
                    });
                }
            });
        })

    });

</script>


</body>
</html>